# -*- coding: utf-8 -*-
# Variable scope
import threading
import socket
import sys
import time

dataX="continue"

print dataX
def some_data(data1):
      
        data = data1          
        return data

class MyThread ( threading.Thread ):
    
   def run ( self ):
       counter=0
       UDP_IP="127.0.0.1"
       UDP_PORT=5003

       sock = socket.socket( socket.AF_INET, # Internet
                      socket.SOCK_DGRAM ) # UDP
      
       sock.bind( (UDP_IP,UDP_PORT) )
           
       while True:
            dataX, addr = sock.recvfrom( 1024 ) # buffer size is 1024 bytes
            counter=counter+1
            print counter ,"received message:", dataX
            if dataX=="quit":
                print "received message:", dataX
                              
                time.sleep(1)
                sock.close()
                sys.exit
            
            
           
class write_dataX(threading.Thread):
   
    def run(self):
        
        test=dataX
        print "test is", test
        
        while test=="quit":
            print test ," degisti"
            sys.exit()
            
            
            
write_dataX().start()
MyThread().start()
print "bitti"

        
        